home *** CD-ROM | disk | FTP | other *** search
- /*Search.c*/
- #include <stdio.h>
- #include <string.h>
- #include "Search.h"
-
- short SearchDocument (char *path, char *args, char *data)
- {
- FILE *f;
- char line [256];
- int i;
- if (f=fopen (path, "r")) {
- data [0]='\0';
- for (i=0;i<strlen(args);i++)
- args[i] = toupper(args[i]);
-
- fgets (line, sizeof (line), f);
-
- while (!feof(f)) {
- line[strlen(line)-1] = '\0';
- if (line[0]=='@') {
- if (!strcmp (&line[1], args)) {
- fgets (line, sizeof (line), f);
- while (!feof(f) && line[0]!='@') {
- strcat (data, line);
- fgets (line, sizeof (line), f);
- }
- }
- else {
- fgets (line, sizeof (line), f);
- }
- }
- else {
- fgets (line, sizeof (line), f);
- }
- }
- return (0);
- }
- else return (-1);
- }